home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / PIL / ImageWin.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  5KB  |  163 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import Image
  5.  
  6. class HDC:
  7.     
  8.     def __init__(self, dc):
  9.         self.dc = dc
  10.  
  11.     
  12.     def __int__(self):
  13.         return self.dc
  14.  
  15.  
  16.  
  17. class HWND:
  18.     
  19.     def __init__(self, wnd):
  20.         self.wnd = wnd
  21.  
  22.     
  23.     def __int__(self):
  24.         return self.wnd
  25.  
  26.  
  27.  
  28. class Dib:
  29.     
  30.     def __init__(self, image, size = None):
  31.         if hasattr(image, 'mode') and hasattr(image, 'size'):
  32.             mode = image.mode
  33.             size = image.size
  34.         else:
  35.             mode = image
  36.             image = None
  37.         if mode not in ('1', 'L', 'P', 'RGB'):
  38.             mode = Image.getmodebase(mode)
  39.         
  40.         self.image = Image.core.display(mode, size)
  41.         self.mode = mode
  42.         self.size = size
  43.         if image:
  44.             self.paste(image)
  45.         
  46.  
  47.     
  48.     def expose(self, handle):
  49.         if isinstance(handle, HWND):
  50.             dc = self.image.getdc(handle)
  51.             
  52.             try:
  53.                 result = self.image.expose(dc)
  54.             finally:
  55.                 self.image.releasedc(handle, dc)
  56.  
  57.         else:
  58.             result = self.image.expose(handle)
  59.         return result
  60.  
  61.     
  62.     def draw(self, handle, dst, src = None):
  63.         if not src:
  64.             src = (0, 0) + self.size
  65.         
  66.         if isinstance(handle, HWND):
  67.             dc = self.image.getdc(handle)
  68.             
  69.             try:
  70.                 result = self.image.draw(dc, dst, src)
  71.             finally:
  72.                 self.image.releasedc(handle, dc)
  73.  
  74.         else:
  75.             result = self.image.draw(handle, dst, src)
  76.         return result
  77.  
  78.     
  79.     def query_palette(self, handle):
  80.         if isinstance(handle, HWND):
  81.             handle = self.image.getdc(handle)
  82.             
  83.             try:
  84.                 result = self.image.query_palette(handle)
  85.             finally:
  86.                 self.image.releasedc(handle, handle)
  87.  
  88.         else:
  89.             result = self.image.query_palette(handle)
  90.         return result
  91.  
  92.     
  93.     def paste(self, im, box = None):
  94.         im.load()
  95.         if self.mode != im.mode:
  96.             im = im.convert(self.mode)
  97.         
  98.         if box:
  99.             self.image.paste(im.im, box)
  100.         else:
  101.             self.image.paste(im.im)
  102.  
  103.     
  104.     def fromstring(self, buffer):
  105.         return self.image.fromstring(buffer)
  106.  
  107.     
  108.     def tostring(self):
  109.         return self.image.tostring()
  110.  
  111.  
  112.  
  113. class Window:
  114.     
  115.     def __init__(self, title = 'PIL', width = None, height = None):
  116.         self.hwnd = None(Image.core.createwindow, title, self._Window__dispatcher, 0 if not width else 0)
  117.  
  118.     
  119.     def __dispatcher(self, action, *args):
  120.         return apply(getattr(self, 'ui_handle_' + action), args)
  121.  
  122.     
  123.     def ui_handle_clear(self, dc, x0, y0, x1, y1):
  124.         pass
  125.  
  126.     
  127.     def ui_handle_damage(self, x0, y0, x1, y1):
  128.         pass
  129.  
  130.     
  131.     def ui_handle_destroy(self):
  132.         pass
  133.  
  134.     
  135.     def ui_handle_repair(self, dc, x0, y0, x1, y1):
  136.         pass
  137.  
  138.     
  139.     def ui_handle_resize(self, width, height):
  140.         pass
  141.  
  142.     
  143.     def mainloop(self):
  144.         Image.core.eventloop()
  145.  
  146.  
  147.  
  148. class ImageWindow(Window):
  149.     
  150.     def __init__(self, image, title = 'PIL'):
  151.         if not isinstance(image, Dib):
  152.             image = Dib(image)
  153.         
  154.         self.image = image
  155.         (width, height) = image.size
  156.         Window.__init__(self, title, width = width, height = height)
  157.  
  158.     
  159.     def ui_handle_repair(self, dc, x0, y0, x1, y1):
  160.         self.image.draw(dc, (x0, y0, x1, y1))
  161.  
  162.  
  163.